use std::io::Read;

use alex_album::{bootstrap, entities};
use sea_orm::EntityTrait;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let db = bootstrap::db_init().await?;
    let mut fp = std::fs::File::open("./examples/id")?;
    let mut id = String::new();
    let _ = fp.read_to_string(&mut id);
    let res = entities::album::Entity::find_by_id(id.to_owned())
        .one(&db)
        .await;

    match res {
        Ok(Some(model)) => {
            println!("{:#?}", model);
        }
        Ok(None) => {
            println!("{:?} ID not found", id);
        }
        Err(e) => println!("{:#?}", e),
    }

    Ok(())
}
